//
//  fxHistroy.cpp
//  balance
//
//  Created by qi mao on 8/5/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//


#include "fxHistroy.h"
#include <fstream>





void fxHistory::initWithFilename(string name){
    ifstream ifile(name.c_str());
    
    period=0;
    for (int i=0;i<60000;i++) {
        for (int j=0; j<7; j++) {
            switch (j) {
                case 0:
                    ifile>>Histroy[i].day;
                    break;
                case 1:
                    ifile>>Histroy[i].time;
                    break;
                case 2:
                    ifile>>Histroy[i].open;
                    break;
                case 3:
                    ifile>>Histroy[i].high;
                    break;
                case 4:
                    ifile>>Histroy[i].low;
                    break;
                case 5:
                    ifile>>Histroy[i].close;
                    break;
                case 6:
                    ifile>>Histroy[i].volume;
                    break;
                default:
                    break;
            }
            //if (Histroy[i].high==0) break;
        }
        //Histroy[i].print();
        //be caution about it!
        period++;
        if (Histroy[i].high==0) break;
        
    }
    cout<<"period="<<period<<endl;
    ifile.close();
}


